package com.qnzw.zjmy.home.ui.activity;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.multidex.MultiDex;

import com.android.volley.Request;
import com.android.volley.VolleyError;
import com.anythink.core.api.ATSDK;
import com.bytedance.sdk.openadsdk.TTAdConfig;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.mediation.init.MediationConfig;
import com.github.gzuliyujiang.oaid.DeviceIdentifier;
import com.github.gzuliyujiang.oaid.IRegisterCallback;
import com.gyf.immersionbar.ImmersionBar;
import com.qnzw.zjmy.wxapi.WXEntryActivity;
import com.qnzw.zjmy.R;
import com.qnzw.zjmy.ad.MediationSplashAd;
import com.qnzw.zjmy.config.UrlAddressConfig;
import com.qnzw.zjmy.config.UrlConfig;
import com.qnzw.zjmy.home.HorizontalNtbActivity;
import com.qnzw.zjmy.home.ui.enums.AdStatusEnum;
import com.qnzw.zjmy.home.ui.enums.RedisEnum;
import com.qnzw.zjmy.home.ui.enums.RiskEnum;
import com.qnzw.zjmy.home.ui.model.ConfigInfo;
import com.qnzw.zjmy.home.ui.model.TrandsName;
import com.qnzw.zjmy.home.ui.model.vo.BaseVo;
import com.qnzw.zjmy.utils.ViewUtils;
import com.qnzw.zjmy.utils.risk.DeviceUtils;
import com.qnzw.zjmy.utils.risk.RiskUtils;
import com.qnzw.zjmy.utils.risk.VirtualApkCheckUtil;
import com.qnzw.zjmy.volley.BaseActivity;
import com.qnzw.zjmy.volley.httpUtil.interfase.HUCCallBackInterfase;
import com.qnzw.zjmy.volley.state.HUCState;

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;

import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONException;


public class SplashActivity extends BaseActivity {

    private static final String TAG = "SplashActivity";

    private VirtualApkCheckUtil virtualApkCheckUtil;
    private RiskUtils riskUtils;
    private DeviceUtils deviceUtils;
    private AlertDialog alertDialog;
    private AlertDialog alertDialogPrivacyProtection;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ImmersionBar.with(this).init();

        String token = getSharedPreferencesToken("token");
        if (StrUtil.isEmpty(token)) {
            showPrivacyProtection();
        } else {
            initData();
//            ImageView logo = findViewById(R.id.splash_logo);
//            Glide.with(this).load(R.drawable.icon_logo).into(logo);
        }


    }

    private void initData() {
        virtualApkCheckUtil = VirtualApkCheckUtil.getSingleInstance();
        deviceUtils = DeviceUtils.getInstance();
        riskUtils = RiskUtils.getInstance();

        MultiDex.install(this);
        DeviceIdentifier.register(this.getApplication(), false, new IRegisterCallback() {
            @Override
            public void onComplete(String clientId, Exception error) {
                // do something
            }
        });
        loading();
        BaseVo baseVo = new BaseVo();
        baseVo.setInfo(getMyUUID());

        hucRequestInterfase.executeStr(this, ConfigInfo.class, HUCState.HUC_REQEUST_CODE_1, Request.Method.POST, UrlConfig.URL_CONFIG_INFO, hucParameInterfase.getRequestParameter(baseVo), true);
    }

    @Override
    public void onSuccessfulStrType(int inputType, Object response) {
        loadDismiss();
        if (inputType == HUCState.HUC_REQEUST_CODE_1 && response instanceof ConfigInfo) {
            ConfigInfo info = (ConfigInfo) response;
//            info.setTa_ku("1");
//            info.setTa_ku_app_id("a678f572e4de46");
//            info.setTa_ku_app_key("a0a41eec18d5d4c633fbe769898524522");
//            //信息流
//            info.setTa_ku_ad_information_flow("b678f5c1cdb3e0,b678f5c1c2d0b4,b678f5c1b5595c,b678f5c1a81ce4,b678f5c19acc8b,b678f5c18bf053,b678f5c181c233,b1g75846m6v9si,b678f5bcc6f2a9");
//            //激励广告
//            info.setIncentive_video("b678f5768b6744,b678f77269fe86,b678f77279f1af,b678f77292a11f,b678f7729f20f4");
//            //插屏广告
//            info.setTa_ku_ad_insert_half_screen("b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5,b678f59e1491c5");
//            //横屏广告
//            info.setTa_ku_banner("b678f713c9e095,b678f713b9cce1,b678f713acc297,b678f713a0140d,b678f71392a825,b678f71386187b,b678f7137993b1,b678f7136cfa9d,b678f7135968b7,b678f7134d6533,b678f71340ff87,b678f71333b3c0");
//            //答题激励广告
//            info.setApp_answer_incentive("b678f5768b6744,b678f77269fe86,b678f77279f1af,b678f77292a11f,b678f7729f20f4");
//            //签到
//            info.setApp_answer_sign_in("b678f5768b6744,b678f77269fe86,b678f77279f1af,b678f77292a11f,b678f7729f20f4");
//            //信息流（答错）
//            info.setApp_flow_answer_incorrectly("b678f5c1cdb3e0,b678f5c1c2d0b4,b678f5c1b5595c,b678f5c1a81ce4,b678f5c19acc8b,b678f5c18bf053,b678f5c181c233,b1g75846m6v9si,b678f5bcc6f2a9");
//            //提现激励广告
//            info.setApp_answer_withdrawal("b678f5768b6744,b678f77269fe86,b678f77279f1af,b678f77292a11f,b678f7729f20f4");
            //*********************
            String taKu = info.getTa_ku();
            String adName = "";
            if (RiskEnum.RISK_YES.getValue().equals(taKu)) {
                adName = RedisEnum.TA_KU.getValue();
                //初始化SDK该接口不会采集用户信息
                ATSDK.init(getApplicationContext(), info.getTa_ku_app_id(), info.getTa_ku_app_key());
                //调用init后请再调用start，否则可能影响广告填充，造成收入下降
                ATSDK.setNetworkLogDebug(true);//应用上线前须关闭
                ATSDK.integrationChecking(this);
                ATSDK.start();
            }
            String groMore = info.getGro_more();
            if (RiskEnum.RISK_YES.getValue().equals(groMore)) {

                adName = RedisEnum.GRO_MORE.getValue();
                //初始化聚合
                initMediationAdSdk(this, info.getApp_id());
                //初始化开屏广告
                MediationSplashAd mediationSplashAd = MediationSplashAd.getInstance();
                mediationSplashAd.init(this, info.getSpread_its_tail());
                mediationSplashAd.loadCacheSplashAd();
            }
            setSharedPreferences(RedisEnum.TA_KU.getKey(), adName);
            if (!TextUtils.isEmpty(info.getInsert_full_screen()) && !info.getInsert_full_screen().equals("null")) {
                setSharedPreferences("insert_full_screen", info.getInsert_full_screen());
            }
            setSharedPreferences("isOpen", taKu);
            setSharedPreferences(RedisEnum.INCENTIVE_VIDEO_CALLBACK.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_incentive_video_callback() : info.getIncentive_video_callback());
            setSharedPreferences(RedisEnum.INCENTIVE_VIDEO.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_incentive_video() : info.getIncentive_video());
            setSharedPreferences(RedisEnum.BANNER.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_banner() : info.getBanner());
            setSharedPreferences(RedisEnum.BANNER_WITH.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_banner_with() : info.getBanner());
            setSharedPreferences(RedisEnum.BANNER_HIGH.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_banner_high() : info.getBanner());
            setSharedPreferences(RedisEnum.SPREAD_ITS_TAIL.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_spread_its_tail() : info.getSpread_its_tail());
            setSharedPreferences(RedisEnum.AD_INSERT_HALF_SCREEN.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_ad_insert_half_screen() : info.getAd_insert_half_screen());
            setSharedPreferences(RedisEnum.AD_INSERT_FULL_SCREEN.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_ad_insert_full_screen() : info.getAd_insert_full_screen());
            setSharedPreferences(RedisEnum.AD_INFORMATION_FLOW.getKey(), RedisEnum.TA_KU.getValue().equals(adName) ? info.getTa_ku_ad_information_flow() : info.getAd_information_flow());
            setSharedPreferences(RedisEnum.DAILY_TASK_FREQUENCY.getKey(), info.getDaily_task_frequency());
            setSharedPreferences("ADCount", Integer.parseInt(info.getDaily_task_frequency()));
            setSharedPreferences(RedisEnum.TIME_INTERVAL.getKey(), info.getTime_interval());
            setSharedPreferences(RedisEnum.SIGN_IN_ONE.getKey(), info.getSign_in_one());
            setSharedPreferences(RedisEnum.SIGN_IN_TWO.getKey(), info.getSign_in_two());
            setSharedPreferences(RedisEnum.SIGN_IN_THREE.getKey(), info.getSign_in_three());
            setSharedPreferences(RedisEnum.SIGN_IN_FOUR.getKey(), info.getSign_in_four());
            setSharedPreferences(RedisEnum.SIGN_IN_FIVE.getKey(), info.getSign_in_five());
            setSharedPreferences(RedisEnum.SIGN_IN_SIX.getKey(), info.getSign_in_six());
            setSharedPreferences(RedisEnum.SIGN_IN_SEVEN.getKey(), info.getSign_in_seven());
            setSharedPreferences(RedisEnum.SIGN_IN_EIGHT.getKey(), info.getSign_in_eight());
            //副广控制 start
            setSharedPreferences(RedisEnum.APP_ANSWER_INCENTIVE.getKey(), info.getApp_answer_incentive());
            setSharedPreferences(RedisEnum.APP_ANSWER_SIGN_IN.getKey(), info.getApp_answer_sign_in());
            setSharedPreferences(RedisEnum.APP_ANSWER_WITHDRAWAL.getKey(), info.getApp_answer_withdrawal());
            setSharedPreferences(RedisEnum.APP_FULL_SCREEN.getKey(), info.getApp_full_screen());
            //副广控制 end
            setSharedPreferences(RedisEnum.APP_BANNER.getKey(), info.getApp_banner());
            setSharedPreferences(RedisEnum.PLAYLET_FREE_SET.getKey(), info.getPlaylet_free_set());
            setSharedPreferences(RedisEnum.WITHDRAWAL_NUMBER_SIGN.getKey(), info.getWithdrawal_number_sign());
            setSharedPreferences(RedisEnum.APP_QQ_COMMUNICATION_GROUP.getKey(), info.getApp_qq_communication_group());
            setSharedPreferences(RedisEnum.APP_QQ_CUSTOMER_SERVICE.getKey(), info.getApp_qq_customer_service());
            setSharedPreferences(RedisEnum.GM_VIDEO.getKey(), info.getGm_video());
            setSharedPreferences(RedisEnum.GM_SHORT_PLAY.getKey(), info.getGm_short_play());
            setSharedPreferences(RedisEnum.TIME_INTERVAL_ANSWER.getKey(), info.getTime_interval_answer());
            setSharedPreferences(RedisEnum.TIME_INTERVAL_ANSWER_ERROR.getKey(), info.getTime_interval_answer_error());
            setSharedPreferences(RedisEnum.TIME_INTERVAL_ANSWER_RECEIVE.getKey(), info.getTime_interval_answer_receive());
            setSharedPreferences(RedisEnum.WX_LOGIN_APP_ID.getKey(), info.getWx_login_app_id());
            setSharedPreferences(RedisEnum.WX_LOGIN_APP_SECRET.getKey(), info.getWx_login_app_secret());

            setSharedPreferences(RedisEnum.RISK_SHARE_OPEN_APP.getKey(), info.getRisk_share_open_app());
            setSharedPreferences(RedisEnum.RISK_WITHDRAWAL_OPEN_APP.getKey(), info.getRisk_withdrawal_open_app());
            setSharedPreferences(RedisEnum.RISK_WX_LOGIN_OPEN_APP.getKey(), info.getRisk_wx_login_open_app());


            setSharedPreferences(RedisEnum.ANSWERINGTIME.getKey(), info.getAnsweringTime());
            setSharedPreferences(RedisEnum.ANSWERTYPE.getKey(), info.getAnswerType());

            setSharedPreferences(RedisEnum.BOOTTOM1.getKey(), info.getBottom_index_tab_trigger());
            setSharedPreferences(RedisEnum.BOOTTOM2.getKey(), info.getBottom_category_tab_trigger());

            int clickCount = deviceUtils.safeParseInt(info.getNext_buttom_click_nums(), 0);
            deviceUtils.saveNextClickCount(this, clickCount);

            //风控拦截
            if (UrlAddressConfig.CHANNEL_TYPE == 1) {
                // if (UrlAddressConfig.CHANNEL_TYPE==4){
                //双开
                String risk_double_open_app = info.getApp_qq_customer_service();
                if (RiskEnum.RISK_YES.getValue().equals(risk_double_open_app)) {
                    boolean flag = virtualApkCheckUtil.checkByCreateLocalServerSocket(deviceUtils.getPackageName(this));
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【双开】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
                //模拟器
                String risk_simulator_app = info.getRisk_simulator_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_simulator_app)) {
                    boolean flag = riskUtils.detectEmulator(this);
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【模拟器】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
                //调试模式
                String risk_developer_mode_app = info.getRisk_developer_mode_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_developer_mode_app)) {
                    boolean flag = deviceUtils.isDeveloperModeEnabled(this);
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【调试模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
                //USB调试模式
                String risk_debug_mode_app = info.getRisk_debug_mode_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_debug_mode_app)) {
                    boolean flag = deviceUtils.isAdbEnabled(this);
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【USB调试模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
                //是否root
                String risk_root_app = info.getRisk_root_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_root_app)) {
                    boolean flag = deviceUtils.isDeviceRooted(this);
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【root】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
                //无障碍模式
                String risk_accessibility_app = info.getRisk_accessibility_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_accessibility_app)) {
                    boolean flag = deviceUtils.isAccessibilityServiceEnabled(this);
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【无障碍模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
                //代理模式
                String risk_id_proxy_app = info.getRisk_id_proxy_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_id_proxy_app)) {
                    boolean flag = deviceUtils.isWifiProxy();
                    if (flag) {
                        onErrorLogin(1, "运行环境异常【代理模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }

                //是否开启了悬浮窗
                String risk_system_alert_window_app = info.getRisk_system_alert_window_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_system_alert_window_app)) {
                    if (deviceUtils.getSystemAlertWindow(this).equals("1")) {
                        onErrorLogin(1, "运行环境异常【悬浮窗模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }

                //是否开启了蓝牙
                String risk_open_bluetooth_app = info.getRisk_open_bluetooth_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_open_bluetooth_app)) {
                    if (deviceUtils.getOpenBluetooth(this).equals("1")) {
                        onErrorLogin(1, "运行环境异常【蓝牙模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }

                //检查SIM卡状态
                String risk_udasim_status_app = info.getRisk_udasim_status_app();
                if (RiskEnum.RISK_YES.getValue().equals(risk_udasim_status_app)) {
                    String NetworkOperatorName = deviceUtils.getNetworkOperatorName(this);
                    if (NetworkOperatorName.isEmpty()) {
                        onErrorLogin(1, "运行环境异常【SIM卡模式】，如有疑问请微信扫码进群联系管理员：" + info.getApp_qq_customer_service());
                        return;
                    }
                }
            }

            String logoutTime = info.getLogoutTime();
            if (CharSequenceUtil.isNotEmpty(logoutTime)) {
                showWithdraw(logoutTime, info.getApp_spread_its_tail());
            } else {
                // 延迟跳转
                new Handler().postDelayed(() -> {
                    String deviceId = getSharedPreferencesToken("token");
                    if (StrUtil.isEmpty(deviceId)) {//是否条状
                        sendIntent(SplashActivity.this, WXEntryActivity.class);
//                        sendIntent(this, WebGameActivity.class);
                        finish();
                    } else {
                        checkReward(info.getTa_ku());
                    }

                }, 4000);

            }
        }
    }

    private void checkReward(String app_spread_its_tail) {
        BaseVo baseVo = new BaseVo();
        baseVo.setToken(getSharedPreferencesToken("token"));
        baseVo.setOaid(getSharedPreferences(RedisEnum.OAID.getKey()));

        hucRequestInterfase.executeStr(new HUCCallBackInterfase() {
            public void onSuccessfulStrType(int inputType, Object response) {
                //开屏控制
                Class className = HorizontalNtbActivity.class;
                if (AdStatusEnum.AD_STATUS_YES.getValue().equals(app_spread_its_tail)) {
                    className = SplashGmActivity.class;
                }
                sendIntent(SplashActivity.this, className);
                finish();
            }

            @Override
            public void onFailStrType(int inputType, Object response) {
                loadDismiss();
                ViewUtils.showRisk(SplashActivity.this, response.toString(), getSharedPreferences(RedisEnum.APP_QQ_CUSTOMER_SERVICE.getKey()));
            }

            @Override
            public void onSuccessfulBitampType(int inputType, Bitmap response) {
                loadDismiss();
                ViewUtils.showRisk(SplashActivity.this, response.toString(), getSharedPreferences(RedisEnum.APP_QQ_CUSTOMER_SERVICE.getKey()));
            }

            @Override
            public void onErrorResponse(int inputType, VolleyError response) {
                loadDismiss();
                ViewUtils.showRisk(SplashActivity.this, response.toString(), getSharedPreferences(RedisEnum.APP_QQ_CUSTOMER_SERVICE.getKey()));
            }

            @Override
            public void onErrorLogin(int inputType, Object response) {
                loadDismiss();
                if (UrlAddressConfig.CHANNEL_TYPE == 1) {
                    ViewUtils.showRisk(SplashActivity.this, response.toString(), getSharedPreferences(RedisEnum.APP_QQ_CUSTOMER_SERVICE.getKey()));
                }
            }

            @Override
            public void onResetLogin(Object response) {
                loadDismiss();
                ViewUtils.showRisk(SplashActivity.this, response.toString(), getSharedPreferences(RedisEnum.APP_QQ_CUSTOMER_SERVICE.getKey()));
            }
        }, TrandsName.class, HUCState.HUC_REQEUST_CODE_5, Request.Method.POST, UrlConfig.URL_CHECK_REWARD, hucParameInterfase.getRequestParameter(baseVo), true);


    }

    //初始化聚合sdk
    private void initMediationAdSdk(Context context, String appId) {
        TTAdSdk.init(context, buildConfig(appId));
        TTAdSdk.start(new TTAdSdk.Callback() {
            @Override
            public void success() {
                //初始化成功
                //在初始化成功回调之后进行广告加载
                // 初始化，最好放到application.onCreate()执行
            }

            @Override
            public void fail(int i, String s) {
                //初始化失败
                Log.d(TAG, "fail: 初始化失败");
            }
        });
    }

    // 构造TTAdConfig
    private TTAdConfig buildConfig(String appId) {
        JSONObject JSONObject = loadJSONFromAsset();
        return new TTAdConfig.Builder().appId(appId) //APP ID
                .useMediation(true)  //开启聚合功能
                .debug(false)  //打开debug开关
                .setMediationConfig(new MediationConfig.Builder().setCustomLocalConfig(JSONObject).build()).themeStatus(0)  //正常模式  0是正常模式；1是夜间模式；
                /**
                 * 多进程增加注释说明：V>=5.1.6.0支持多进程，如需开启可在初始化时设置.supportMultiProcess(true) ，默认false；
                 * 注意：开启多进程开关时需要将ADN的多进程也开启，否则广告展示异常，影响收益。
                 * CSJ、gdt无需额外设置，KS、baidu、Sigmob、Mintegral需要在清单文件中配置各家ADN激励全屏xxxActivity属性android:multiprocess="true"
                 */.supportMultiProcess(false)  //支持多进程
                .build();
    }

    public JSONObject loadJSONFromAsset() {
        String json = null;
        try {
            InputStream is = getResources().openRawResource(R.raw.ad_config);
            int size = is.available();
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer, "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return null;
        } catch (JSONException ex) {
            ex.printStackTrace();
            return null;
        }
        try {
            return new JSONObject(json);
        } catch (org.json.JSONException e) {
            e.printStackTrace();
            return null;
        }
    }


    private void showWithdraw(String logoutTIme, String info) {
        //判断提现账号
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        // dialog.setTitle("绑定姓名");
        View root = LayoutInflater.from(this).inflate(R.layout.pop_logout_time, null);
        dialog.setView(root);
        TextView textView = root.findViewById(R.id.tv_web);
        textView.setText("您已于" + logoutTIme + "申请注销账户15天内可以申请");
        root.findViewById(R.id.tv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 延迟跳转
                String deviceId = getSharedPreferencesToken("token");
                if (StrUtil.isEmpty(deviceId)) {//是否条状
                    sendIntent(SplashActivity.this, WXEntryActivity.class);
                } else {
                    //开屏控制
                    Class className = HorizontalNtbActivity.class;
                    if (AdStatusEnum.AD_STATUS_YES.getValue().equals(info)) {
                        className = SplashGmActivity.class;
                    }
                    sendIntent(SplashActivity.this, className);
                }
                finish();
            }
        });
        root.findViewById(R.id.tv_no).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.dismiss();
                finish();
            }
        });
        alertDialog = dialog.create();
        alertDialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
        alertDialog.setCancelable(false);
        alertDialog.show();
    }


    private void showPrivacyProtection() {
        //判断提现账号
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        View root = LayoutInflater.from(this).inflate(R.layout.pop_privacy_protection, null);
        dialog.setView(root);
        TextView textView = root.findViewById(R.id.tv_content);

        SpannableString spannableString = new SpannableString("请您在使用我们的服务前仔细阅读《用户协议》及《隐私政策》请您知悉，您同意隐私政策伐代表您已了解应用提供的功能，以及功能运行所需的必要个人信息，并不代表您已同意我们可以收集非必要个人信息，非必要个人信息会根据您使用过程中的授权情况单独征求您的同意。");
        spannableString.setSpan(
                new ClickableSpan() {
                    @Override
                    public void onClick(@NonNull View widget) {
                        sendIntent(SplashActivity.this, WebViewActivity.class, "用户协议");
                    }

                    @Override
                    public void updateDrawState(@NonNull TextPaint ds) {
                        super.updateDrawState(ds);
                        ds.setColor(getResources().getColor(R.color.home)); // 设置文本颜色
                        ds.setUnderlineText(true); // 设置文本下划线
                    }
                },
                15,
                21,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
        );
        spannableString.setSpan(
                new ClickableSpan() {
                    @Override
                    public void onClick(@NonNull View widget) {
                        sendIntent(SplashActivity.this, WebViewActivity.class, "隐私政策");
                    }

                    @Override
                    public void updateDrawState(@NonNull TextPaint ds) {
                        super.updateDrawState(ds);
                        ds.setColor(getResources().getColor(R.color.home)); // 设置文本颜色
                        ds.setUnderlineText(true); // 设置文本下划线
                    }
                },
                22,
                28,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
        );
        // 确保 TextView 能接收并处理点击事件
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        textView.setText(spannableString);
        root.findViewById(R.id.tv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialogPrivacyProtection.dismiss();
                initData();
//                ImageView logo = findViewById(R.id.splash_logo);
//                Glide.with(SplashActivity.this).load(R.drawable.icon_logo).into(logo);
            }
        });
        root.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialogPrivacyProtection.dismiss();
                finish();

            }
        });
        alertDialogPrivacyProtection = dialog.create();
        alertDialogPrivacyProtection.getWindow().setBackgroundDrawableResource(R.color.transparent);
        alertDialogPrivacyProtection.setCancelable(false);
        alertDialogPrivacyProtection.show();
    }

    private String getMyUUID() {
        final String androidId = android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        return androidId;
    }
}